<template>
  <div class="index-container">
    <div class="index-header">
      <div class="index-header-left">
        <div class="index-header-left-title">欢迎登录</div>
      </div>
    </div>
  </div>
</template>
<script setup>
import { onMounted } from "vue";
import useUserStore from "@/store/modules/user";
import usePermissionStore from "@/store/modules/permission";

// 获取用户和权限store实例
const userStore = useUserStore();
const permissionStore = usePermissionStore();

onMounted(() => {
  // 如果用户已登录且有角色信息，但侧边栏路由为空，则重新生成路由
  if (userStore.roles.length > 0 && permissionStore.sidebarRouters.length === 0) {
    permissionStore.generateRoutes().then(() => {
      // 路由生成完成后，强制刷新当前页面以确保侧边栏能正确显示
      window.location.reload();
    });
  }
});
</script>
